* Firm organization with multiple establishments
* Appendix A: Tables A.21, A.23-A.26

clear all 
set matsize 2000
set more off

capture log close
log using log/35_cmrh-p_replication_est.log, replace

********************************************************************************
********************************************************************************
* Use individual-level dataset

use data/CMRH_2000-2010_p_layer-ind.dta if hauptbet == 0 & count_est > 1, clear

merge m:1 betnr jahr using data/est_count_mgmt_unt_panel.dta
drop _merge

*table A.21: wage distribution by layer
*****************************

tabstat tentgelt, by(layer) s(n mean sd p5 p10 q p90 p95)
tab layer, missing

********************************************************************************
********************************************************************************
* Use firm-level dataset

use data/CMRH_2000-2010_p_est_layer-firm.dta if hauptbet == 0 & count_est > 1, clear

*** DATASET NEEDS TO VARY AT ESTABLISHMENT-YEAR LEVEL
duplicates report betnr jahr

*tables A.23 and A.24: statistics by layers
******************************
table count_mgmt_est, c(n empl_est mean empl_est mean avg_wage median avg_wage)
table count_mgmt_unt, c(n empl_est mean empl_est mean avg_wage median avg_wage)

*table A.25: combinations of layers
***************************************************
tab2 count_mgmt_unt count_mgmt_est

*table A.26: fraction of firms with correct ordering
***************************************************
tabulate correctlyr count_mgmt_est, col nofreq
tabulate correctlyr count_mgmt_est [aweight=empl_est], col nofreq
//	# obs
tabulate correctlyr count_mgmt_est
tabulate correctlyr count_mgmt_est [aweight=empl_est]
******************** end table

log close

clear all
